package design.mode.dispatcher.util.groovydemo;

import design.mode.dispatcher.bean.Report;
import design.mode.dispatcher.util.GenerateIdUtils;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import org.apache.poi.ss.usermodel.Cell;

import java.util.HashMap;
import java.util.Map;

public class ReportFillStrategy implements FillStrategy {

    @Override
    public Object process(Cell cell,String expression) {
        Report report = new Report("互换", "收益互换(Sno)", "市场发展部", GenerateIdUtils.generateUniqueId(),
                GenerateIdUtils.generateValue(), GenerateIdUtils.generatePercent(), GenerateIdUtils.generatePercent(), 1);
        Map<String,Object> dataMap = new HashMap<>();
        dataMap.put("bean",report);
        GroovyShell shell = new GroovyShell(new Binding(dataMap));
        return shell.evaluate(expression);
    }

}
